package com.cnsugar.ai.face;

import com.cnsugar.ai.face.bean.FaceIndex;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author ChenZhangKun
 * @Date 2020/4/24 13:31
 */
@SuppressWarnings("all")
public class LoadFaceThread implements Runnable {

    // 是否执行完毕的标记
    private boolean isCompelete = false;
    // 需要注册的线程集合
    private List<FaceIndex> list = new ArrayList<>();

    public LoadFaceThread(List<FaceIndex> list) {
        // 初始化该线程需要加载的人脸集合
        this.list = list;
    }

    @Override
    public void run() {

        SeetafaceBuilder.logger.info("load face data...");
        for (FaceIndex faceIndex : list) {
            try {
                SeetafaceBuilder.register(faceIndex.getKey(), faceIndex);
            } catch (Exception ex) {
                isCompelete = true;
                ex.printStackTrace();
            }
        }
        // 执行完毕，更新标记
        isCompelete = true;
    }

    public enum FacedbStatus {
        READY, LOADING, OK, INACTIV;
    }

    public boolean getStatus() {
        return isCompelete;
    }
}
